//接口的函数应用
{
    interface SumItf {
        (num1: number, num2: number): number
    }
    let sum: SumItf = (num1: number, num2: number): number => {
        return num1 + num2
    }
    console.log(sum(1, 2))
    //接口数组，对象使用


    //数组
    let arr: Array<number> = [12, 2, 3]
    let arr1: number[] = [12, 2, 3]
    interface ArrItf {
        [index: number]: number
    }
    let arr2: ArrItf = [12, 2, 3]


    //对象
    interface ObjItf {
        name: string, age: number
    }
    let obj: ObjItf = { name: '整数', age: 2 }

    interface ObjItf1 {
        [index: string]: string | number | CountItf
    }
    let obj1: ObjItf1 = { name: '整数', age: 2 }

    interface CountItf {
        a: number
    }
    let obj2: ObjItf1 = { name: '整数', age: 2, count: { a: 1 } }

    //类的使用接口
    interface PersonItf {
        name: string
        eat(food: string): void
    }
    class Person {
        public age!: number
        public sex: boolean = true
    }
    class Male extends Person implements PersonItf {
        name: string = '张三'
        eat(food: string): void {
            console.log(this.name + '吃' + food)
        }

    }
    let m: Male = new Male()
    console.log(m.eat('饺子'));
    console.log(m.name, m.age, m.sex);
}
